import { useModel } from "umi";
import compress from "gql-compress";

const useCreatePosition = () => {
    const { graphqlFetch } = useModel("global");

    const createPosition = async (variables) => {
        let res = await graphqlFetch({
            query: CreateOrganizationPosition,
            variables,
        });
        return res ? true : false;
    };

    return { createPosition };
};

const CreateOrganizationPosition = compress(`mutation MyMutation(
    $opUuid: UUID!
    $opName: String!
    $opDesc: String
  ) {
    createOrganizationPosition(
      input: {
        organizationPosition: {
          opUuid: $opUuid
          opName: $opName
          opDesc: $opDesc
        }
      }
    ) {
      clientMutationId
    }
}`);

export default useCreatePosition;
